package com.yaorange.api;

import com.yaorange.nongjt.service.INjtAreaService;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.nongjt.service.INjtAreaService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/area")
public class NjtAreaAPI extends BaseController {

    @Autowired
    private INjtAreaService njtAreaService;

    /**
     * @return {@link AjaxResult }
     * @descripiton 查询省市区镇列表
     */// http://localhost:8080/api/area/queryListRoot
    @GetMapping("/queryListRoot")
    public AjaxResult queryListRoot() {
        return AjaxResult.success(njtAreaService.queryDefaultRootList());
    }

    // http://localhost:8080/api/area/queryChildrenByParentCode?parentCode=510300000
    @GetMapping("/queryChildrenByParentCode")
    public AjaxResult queryChildrenByParentCode(@Param("parentCode") String parentCode) {
        return AjaxResult.success(njtAreaService.selectNjtAreaListByParentCode(parentCode));
    }

}
